package com.victualler.product.customer.service.impl;

import com.victualler.core.base.service.impl.BaseDetailServiceImpl;
import com.victualler.product.customer.entity.CustomerAddressDao;
import com.victualler.product.customer.repository.CustomerAddressQueryRepository;
import com.victualler.product.customer.repository.CustomerAddressRepository;
import com.victualler.product.customer.service.CustomerAddressService;
import org.springframework.stereotype.Service;

/**
 * @Author: Guoshichang
 * @Date: Create in 17:03 2018/4/5
 * @Discription:  Dict字典类型对应的服务层
 */
@Service
public class CustomerAddressServiceImpl extends BaseDetailServiceImpl<CustomerAddressDao,CustomerAddressRepository,CustomerAddressQueryRepository> implements CustomerAddressService {
    /**
     * @author Guoshichang
     * @since 12:40 on 2019/1/18.
     * @param name 联系人名
     * @param customerId 客户id
     * @return
     * @Function
     */
    public CustomerAddressDao getByName(String name,Long customerId) {
        for (CustomerAddressDao customerAddressDao : this.getByParentId(customerId)) {
            if(customerAddressDao.getName().equals(name)) {
                return customerAddressDao;
            }
        }
        return null;
    }
}
